﻿@model IEnumerable<WebVideo.EntityBusiness>
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-1.7.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-ui-1.8.16.custom.min.js")" type="text/javascript"></script>

<script type="text/javascript">
    function deletehis(Username) {
        var c = confirm('Continue delete?');
        if (c) $('#hs' + Username).fadeOut(function () {
            var getURL = '@Url.Action("Delete", "Business")';

            $.get(getURL, { "Username": Username }, function (data) {
                if (data == "error") //error
                {
                    $('#nofError').show();
                    $('#nofSuccess').hide();
                    $('#msgNofError').text("Cannot Delete Record");
                }
                else {
                    jQuery(this).remove();
                    $('#nofError').hide();
                    $('#nofSuccess').show();
                    $('#msgNofSuccess').text("Delete Record Ok");
                }
            });
        });
        return false;
    }
</script>
<ul class="maintabmenu multipletabmenu">
    <li class="current"><a href="@Url.Action("Index", "Business")" >Index</a></li>
    <li class="current"><a href="@Url.Action("Insert", "Business")" >Insert</a></li>
    <li class="current"><a href="#" onclick="return saveExcel();" >Xuất Thông tin doanh nghiệp</a></li>
</ul>

<div class="contenttitle">
    <h2 class="form"><span>List Business</span></h2>
</div>
<!--contenttitle-->
<table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="dyntable">
    <colgroup>
        <col class="con0" />
        <col class="con1" />
        <col class="con0" />
        <col class="con1" />
        <col class="con0" />
        <col class="con1" />
        <col class="con0" />
    </colgroup>
    <thead>
        <tr>
            <th class="head0">Username</th>
            <th class="head1">Tên Doanh Nghiệp</th>
            <th class="head0">Email</th>
            <th class="head1">Trạng Thái</th>
            <th class="head0">Ngày Tạo</th>
            <th class="head1">Hành Động</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th class="head0">Username</th>
            <th class="head1">Tên Doanh Nghiệp</th>
            <th class="head0">Email</th>
            <th class="head1">Trạng Thái</th>
            <th class="head0">Ngày Tạo</th>
            <th class="head1">Hành Động</th>
        </tr>
    </tfoot>
    <tbody>
        @{
            foreach (var item in Model)
            {
                string idd = "hs" + item.UserName.ToString();
            <tr class="gradeX" id="@idd">
                <td>
                    @Html.DisplayFor(modelitem => item.UserName)
                </td>
                <td>
                    @Html.DisplayFor(modelitem => item.CompanyName)
                </td>
                <td>
                    @Html.DisplayFor(modelitem => item.Email)
                </td>

                <td>
                    @{
                if (@Html.DisplayFor(modelitem => item.Status).ToString() == "1")
                {
                        <span class="field">Đang hoạt động</span>
                }
                else
                {
                        <span class="field" style="color: red;">Đã bị BAN</span>
                }   
                    }

                </td>
                <td>
                    @Html.DisplayFor(modelitem => item.Date)
                </td>
                <td class ="eddelete">

                    @Html.ActionLink(" ", "Edit", new { US = @item.UserName }, new { @class = "view",title="view" })
                                       
                        @{
                            if (@Html.DisplayFor(modelitem => item.Status).ToString() == "1")
                            {
                            @Html.ActionLink(" ", "Ban", new { US = @item.UserName, l = 2 }, new { @class = "ban",title="Ban" })
                             }
                            else
                            {
                            @Html.ActionLink(" ", "Ban", new { US = @item.UserName, l = 1 }, new { @class = "unban",title="Unban" })
                             }   
                        }
                    <a href="#" class="delete" title="Delete" , onclick='deletehis("@item.UserName")' ></a>
                </td>
            </tr> 
            }                       
        }
    </tbody>
</table>


<script type="text/javascript"  src="@Url.Content("~/Content/cssAdmin/js/custom/tables.js")" ></script>
<script type="text/javascript"  src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery.dataTables.min.js")" ></script>

<script>
    function saveExcel() {
        var postUrl = '@Url.Action("saveExcel", "Business")';
        $.post(postUrl, function (data) {
            var strTemp = '@Url.Content("~/Content/!!!")';
            strTemp = strTemp.replace("!!!", data);
            window.location = strTemp;
        });
        return false;
        }
</script>

